//
//  SCSetController.m
//  shangcheng
//
//  Created by 张艳江 on 2019/6/6.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCSetController.h"
#import "SCAddressController.h"

@interface SCSetController ()

@property (strong, nonatomic) NSArray *titles;
@property (strong, nonatomic) NSArray *images;

@end

@implementation SCSetController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"更多设置";
    self.tableView.backgroundColor = BGColor;
    self.tableView.separatorColor = RGB(239, 239, 239);
    self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 0.7)];
    
    self.titles = @[@"地址管理"];
    //self.images = @[@"card",@"recommend",@"infoset"];
    
    //setfooview
    [self setFootView];
}
- (void)setFootView{
    
    UIView *footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 70)];
    self.tableView.tableFooterView = footView;
    
    UIButton *logoutBtn = [UIButton createButtonFrame:CGRectMake(12, 20, kScreenW - 24, 44) groundColor:RGB(233, 55, 62) title:@"退出登录" titleColor:[UIColor whiteColor] font:SCFont(16) target:self action:@selector(clickLogoutBtn)];
    logoutBtn.layer.cornerRadius = 3.0f;
    logoutBtn.clipsToBounds = YES;
    [footView addSubview:logoutBtn];
}
- (void)clickLogoutBtn{
    
    [MyTool alertTitle:@"您确定要退出登录?" mesasge:nil preferredStyle:UIAlertControllerStyleAlert confirmHandler:^(UIAlertAction * _Nonnull action) {
        [MyTool logout];
    } cancleHandler:nil viewController:self];
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.titles.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = self.titles[indexPath.row];
    cell.textLabel.font = SCFont(15);
    //cell.imageView.image = [UIImage imageNamed:self.images[indexPath.row]];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    SCAddressController *vc = [[SCAddressController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
